package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Customer;
import com.atguigu.jxc.service.CustomerService;
import com.google.gson.JsonObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class CustomerController {
    @Autowired
    private CustomerService customerService;

    // 获取消费者信息
    @PostMapping("/customer/list")
    public Map<String,Object> customerList(Integer page, Integer rows, String  customerName){
       return customerService.customerList(page,rows,customerName);
    }
    // 保存和 修改消费者 信息
    @PostMapping("/customer/save")
    public ServiceVO saveOrUpdate(Long customerId, Customer customer){
          customerService.saveOrUpdate(customerId,customer);
        return new ServiceVO(100,"请求成功",null);
    }
    // 实现用户的删除
    @PostMapping("/customer/delete")
    public ServiceVO delete(@RequestParam("ids") List<String> ids){
         customerService.delete(ids);
         return new ServiceVO(100,"请求成功",null);
    }
}
